<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 生成器解决异步编程
        function *gen(){
            yield '一直没有耳朵';
            console.log('111');
            yield '一直没有眼睛';
            console.log('222');
            yield '真奇怪';
            console.log('333');
            yield '阿拉拉';
            console.log('444');
        }
        let iterator = gen();
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
    </script>
</body>
</html>